package com.hankol.community.adapter

import com.baselibrary.bean.ReleaseTopicBean
import com.baselibrary.extension.checkNotNull
import com.baselibrary.extension.checkValue
import com.baselibrary.manager.SensorsDataManager
import com.baselibrary.router.ActivityRouter
import com.baselibrary.utils.*
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.community.R
import java.util.HashMap

/**
 */
class HotTopicChildAdapter : BaseQuickAdapter<ReleaseTopicBean.DataBean, BaseViewHolder>(R.layout.item_dynamic_search_topic) {
    override fun convert(helper: BaseViewHolder, bean: ReleaseTopicBean.DataBean) {
        helper.setText(R.id.tv_searchTopic_title, "#${bean.name.checkValue()}").setText(R.id.tv_searchTopic_browse, "${bean.dynamicNum}条内容 · ${NumberUtils.formatBigNum(bean.viewNum.toString())}浏览").setText(R.id.tv_searchTopic_des, bean.desc)
        GlideUtils.loadImg_101(mContext.applicationContext,if(bean.img.checkNotNull())bean.img else bean.cover, helper.getView(R.id.round_searchTopic_cover))
        helper.itemView.setOnClickListener {
            if (bean.checkNotNull()) {
                if (!DoubleClickHelper.isOnDoubleClick()) {
                    //跳转话题详情
                    SensorsDataManager.instance.classifyTopicClick(bean.categoryId.toString(), bean.tagCategoryName, bean.id.toString(), bean.name)
                    val hashMap = HashMap<String, Any>()
                    hashMap["tid"] = bean.id
                    hashMap["tsource"] = "话题分类页"
                    ARouterUtils.jump(ActivityRouter.COMMUNITY.COMMUNITY_TOPIC_DETAIL, hashMap)
                }
            }
        }
    }

}